package com.agent.commons.utils;

import com.benjaminwan.ocrlibrary.OcrResult;
import io.github.mymonstercat.Model;
import io.github.mymonstercat.ocr.InferenceEngine;

/**
 * 图片识别工具类
 */
public class OCRUtil {
    /**
     * 进行光学识别
     * @param imgPath
     * @return
     */
    public static String ocr(String imgPath){
        //指定OCR识别模型
        InferenceEngine inferenceEngine =InferenceEngine.getInstance(Model.ONNX_PPOCR_V4);
        //获取识别结果
        OcrResult ocrResult = inferenceEngine.runOcr(imgPath);
        return ocrResult.getStrRes();
    }
}
